package game.engine.base

import android.graphics.*
import com.daidai.spinner.R

//
//// 渲染管理
//// TODO: 后面切换成 opengl es 3.0
//// 1. 现在简单的 单个渲染
//
//class RDImage2d(
//    var bitmap: Bitmap,
//    var rect:Rect = Rect(),
//    var isSubRect:Boolean = false // true表示是取图片的部分区域,false表示渲染的是整张图片
//)
//
//class RDItem(
//    var rect:RectF = RectF(),
//    var rdImage2d: RDImage2d
//)


// 直接做成资源管理
class Graphics {

    val testBitmap : Bitmap
    val bgBitmap :Bitmap
    val infoBgBitmap: Bitmap
    val wordBitmap1:Bitmap
    val wordBitmap2:Bitmap
    val wordBitmap3:Bitmap
    val titleBitmap : Bitmap
    val coinBitmap:Bitmap
    val timeBitmap:Bitmap

    val hbBitmap1:Bitmap
    val hbBitmap2:Bitmap

    init {
        val res = Director.instance.gameApp.activity.resources
        testBitmap = BitmapFactory.decodeResource(res, R.drawable.lyh_coin_big)
        bgBitmap = BitmapFactory.decodeResource(res, R.drawable.lyh_redrain12)
        infoBgBitmap = BitmapFactory.decodeResource(res, R.drawable.dd_info_bg)
        wordBitmap1 = BitmapFactory.decodeResource(res, R.drawable.dd_num1)
        wordBitmap2 = BitmapFactory.decodeResource(res, R.drawable.dd_num2)
        wordBitmap3 = BitmapFactory.decodeResource(res, R.drawable.dd_num3)
        titleBitmap = BitmapFactory.decodeResource(res,R.drawable.dd_hby_title)
        coinBitmap = BitmapFactory.decodeResource(res,R.drawable.dd_small_coin)
        timeBitmap = BitmapFactory.decodeResource(res,R.drawable.dd_time_icon)

        hbBitmap1 = BitmapFactory.decodeResource(res,R.drawable.dd_hb1)
        hbBitmap2 = BitmapFactory.decodeResource(res,R.drawable.dd_hb2)
    }

    fun release(){
        testBitmap.recycle()
        bgBitmap.recycle()
        infoBgBitmap.recycle()
        wordBitmap1.recycle()
        wordBitmap2.recycle()
        wordBitmap3.recycle()
        titleBitmap.recycle()
        coinBitmap.recycle()
        timeBitmap.recycle()
        hbBitmap1.recycle()
        hbBitmap2.recycle()
    }
}


